#include "ddarray.h"
#include <crtdbg.h>

struct Pixel 
{
	char r, g, b;
};

void print_ar ( DDArray * ar )
{
	int v;
	size_t i, j;
	for (j=0; j<ar->hight; j++)
	{
		for (i=0; i<ar->lenght; i++)
		{
			v = *(int*)get_element(ar,i,j);
			if (i == ar->lenght -1)
			{
				printf( "%d\n", v);
			}
			else
			{
				printf("%d ", v);
			}
		}
	}
}

void zapolnit_ar ( DDArray * ar, int a)
{
	size_t i, j;
	for (j=0; j<ar->hight; j++)
	{
		for (i=0; i<ar->lenght; i++)
		{
			put_element(ar, i, j, &a);
		}
	}
}



void main()
{
	int d, c;
	DDArray * p = create(10, 10, sizeof(int));
	DDArray * b = create(8, 8, sizeof(int));

	c=5;
	put_element(p,5,5, &c);
	d = *(int*) get_element( p,5, 5);

	c=1;
	zapolnit_ar (b,c);
	print_ar (p);
	printf("\n");

	c=4;
	zapolnit_ar ( p, c);
	print_ar (p);
	printf("\n");

	put_element(p,5,5,&c);

	p = resize( p, 4, 4);	
	print_ar (p);
	printf("\n");

	zapolnit_ar (p,c);
	print_ar (p);
	copy_dd ( b, p, 0, 0);
	//d = *(int*)get_element(p,5,5);
	print_ar (p);
	printf("\n");
	p = resize (p, 6, 7);
	//copy_dd ( b, p, 2, 9);
	print_ar (p);
	printf("\n");
	printf("\n");
	print_ar (b);
	destroy_array(p);
	destroy_array(b);
	//printf( "%d\n", d);
	_CrtDumpMemoryLeaks();
	system("pause");
}